package day02;

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        //创建输入
        Scanner scan=new Scanner(System.in);
        String str=scan.nextLine();
        //将字符串准化为数组，便于进行后续操作
        char[]ch=str.toCharArray();
        //将数组进行反转
        reverse(ch,0,ch.length);
        //建立下标进行遍历
        int index=0;
        while(index< ch.length){
            //第二下标，寻找反转的右边界
            int j=index;
            while(j< ch.length&&ch[j]!=' '){
                j++;
            }
            //进行子字符串的反转
            reverse(ch,index,j-1);
            index=j+1;
        }
        //重新建立数组
        String str1=new String(ch);
        System.out.println(str1);
    }

    private static void reverse(char[] ch, int i, int length) {
        int start=i;
        int end=length;
        while(start<end){
            char temp=ch[start];
            ch[start]=ch[end];
            ch[end]=temp;
            start++;
            end--;
        }
    }
}